/*
* @Author: chenggh
* @Date: 2025-06-21
* @Link to Problem : 62304135386136393339346365373340bfebea318fd008d8f60d257088
*/
#include <iostream>
#include <set>
#include <vector>
using namespace std;
int main(){
	int n, m; cin >> n >> m;
	multiset<int> h;
	vector<int> t;
	for(int i = 0, temp; i < n; i++){
		cin >> temp;
		h.insert(temp);
	}
	for(int i = 0, temp; i < m; i++){
		cin >> temp;
		t.push_back(temp);
	}
	for(auto x: t){
		auto it = h.upper_bound(x);
		if(it == h.begin()) {
			cout << "-1" << endl;
			continue;
		}
		it--;
		cout << *it << endl;
		h.erase(it);
	}
	return 0;
}